'''
Created on Jun 6, 2012

@author: thomas_dao
'''
from google.appengine.ext import ndb
from entity.entity import Comment


@ndb.tasklet
def get_by_author(author_key, **q_options):
    qry = Comment.query(Comment.author == author_key).order(Comment.created_time)
    data = yield qry.fetch_async(20, **q_options)
    raise ndb.Return(data)

    
@ndb.tasklet
def get_by_commentable(commentable_key, **q_options):
    qry = Comment.query(Comment.commentable == commentable_key).order(-Comment.created_time)
    data = yield qry.fetch_async(20, **q_options)
    raise ndb.Return(data) 
